package com.dst.controller;

import com.dst.dao.PhoneDao;
import com.dst.dao.impl.PhoneDaoImpl;
import com.dst.eneity.Brand;
import com.dst.eneity.Phone;
import com.dst.service.BrandService;
import com.dst.service.PhoneService;
import com.dst.service.impl.BrandServiceImpl;
import com.dst.service.impl.PhoneServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.List;

//@WebServlet(urlPatterns = "/phone/selectAllController")
public class SelectAllController extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        BrandService brandService = new BrandServiceImpl();
        PhoneService phoneService = new PhoneServiceImpl();
        List<Brand> brands = brandService.selectAllBrandService();

        HttpSession session = req.getSession();
        session.setAttribute("brands",brands);

        resp.sendRedirect(req.getContextPath()+"/phone-list.jsp");
    }
}
